<?php
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
*/
include 'inc/PAGE.php';
$p = new PAGE("");

$loginOk = $p->s()->getvar("loginOk");
$username = $p->s()->getvar("username");
$type = $p->s()->getvar("type");

if($loginOk==1  && strlen($username)>0 && $type==USER) {
    $selectbook = $_GET['selectbook'];
    //$p->t()->debug($selectbook);
    $sql = "SELECT id FROM users WHERE username='".$username."'";
    $r = $p->db()->resultasarray($sql);
    $user_id = $r[0][0];
    for($i=0;$i<count($selectbook);$i++){
        $sql = "INSERT INTO borrowed(id,books_id,users_id) VALUES(null,".$selectbook[$i].",".$user_id.")";
        $p->db()->insert($sql);
    }
    header("Location: ./ze_book_borrow.php");

}else {
    header("Location: ./index.php");
}
?>
<a href="index.php"><br/>index.php</a>